/*
 * Copyright 2011 Clean GWT
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.cleangwt.web.shared;

import java.util.List;
import java.util.Map;

//import org.codehaus.jackson.annotate.JsonIgnore;
//import org.codehaus.jackson.map.annotate.JsonSerialize;

/**
 * The paged criteria with sorting fields.
 * 
 * @author Jess
 * @version 1.0
 * @since 1.0
 */
public class PagedCriteria {

  public static final String SORT_ASC = "asc";
  public static final String SORT_DESC = "desc";

  private Map<String, Object> criteria;
  private int pageSize;
  private int pageStart;

  /**
   * The names of sorted column.
   */
  private List<String> sortedColumns;

  /**
   * The sorted directions in types of {@value #SORT_ASC}, {@value #SORT_DESC}.
   */
  private List<String> sortedDirections;

  /**
   * @return the criteria
   */
  public Map<String, Object> getCriteria() {
    return criteria;
  }

  /**
   * @return the pageSize
   */
  public int getPageSize() {
    return pageSize;
  }

  /**
   * @return the pageStart
   */
  public int getPageStart() {
    return pageStart;
  }

  /**
   * Gets the parameter of key.
   * 
   * @param key the key
   * @return the parameter of key
   */
  //@JsonIgnore
  public Object getParameter(String key) {
    if (criteria == null) {
      return null;
    }
    return criteria.get(key);
  }

  /**
   * @return the sortedColumns
   */
  //@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
  public List<String> getSortedColumns() {
    return sortedColumns;
  }

  /**
   * @return the sortedDirections
   */
  //@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
  public List<String> getSortedDirections() {
    return sortedDirections;
  }

  /**
   * @param criteria the criteria to set
   */
  public void setCriteria(Map<String, Object> criteria) {
    this.criteria = criteria;
  }

  /**
   * @param pageSize the pageSize to set
   */
  public void setPageSize(int pageSize) {
    this.pageSize = pageSize;
  }

  /**
   * @param pageStart the pageStart to set
   */
  public void setPageStart(int pageStart) {
    this.pageStart = pageStart;
  }

  /**
   * @param sortedColumns the sortedColumns to set
   */
  public void setSortedColumns(List<String> sortedColumns) {
    this.sortedColumns = sortedColumns;
  }

  /**
   * @param sortedDirections the sortedDirections to set
   */
  public void setSortedDirections(List<String> sortedDirections) {
    this.sortedDirections = sortedDirections;
  }

}